-
-
Notifications
You must be signed in to change notification settings - Fork 287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add authenticated session to app server context #3157
Add authenticated session to app server context #3157
Conversation
Looks like with the recent changes we can redirect to the sign-in page with React Router: 172d2c3 About the flaky Firefox test mentioned in #3179 (comment) I just added those console errors to the ignore list in this test, i think it should be fine to do that? |
| :---------- | :----------------------------------------------------------------- | :---------------------------------------------------------------------------------- | | ||
| `cookies` | `Record<string, string>` | A dictionary mapping cookie name to cookie value. | | ||
| `setCookie` | `(name: string, value: string) => void` | Use to set a cookie `name` with `value`. | | ||
| `user` | `{ name: string; email: string; avatar: string; roles: string[] }` | Get current [authenticated](/toolpad/concepts/authentication/) logged-in user data. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Let's add a separate table for this interface?
- Would it make sense to call this
session
instead ofuser
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
session
sounds good, it's what it's called in @auth/core
too, user
might be a bit too generic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made these changes, ended up having session
in context which has a user
property with this data.
Also covered this in one of the authentication tests (since the user needs to be logged-in to see the context session data).
68aab7f
to
d30af5e
Compare
@apedroferreira Would it make sense to also add user info in the page state for components to bind to? e.g. like https://docs.retool.com/reference/apps/global/objects/current_user |
It would be nice, I've created an issue #3209. |
Add authenticated
session
to server context so that it can be retrieved in custom functions.Had to move some things around between
@mui/toolpad-core
and@mui/toolpad-utils
, let me know if it could be set up differently.Also updated docs with an example, and covered in tests.